package com.ruoyi.driver.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.driver.domain.TbDriverCarInfo;
import com.ruoyi.driver.service.ITbDriverCarInfoService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 网约车信息Controller
 * 
 * @author ruoyi
 * @date 2025-08-27
 */
@RestController
@RequestMapping("/info")
public class TbDriverCarInfoController extends BaseController
{
    @Autowired
    private ITbDriverCarInfoService tbDriverCarInfoService;

    /**
     * 查询网约车信息列表
     */
    //@RequiresPermissions("driver:info:list")
    @GetMapping("/list")
    public TableDataInfo list(TbDriverCarInfo tbDriverCarInfo)
    {
        startPage();
        List<TbDriverCarInfo> list = tbDriverCarInfoService.selectTbDriverCarInfoList(tbDriverCarInfo);
        return getDataTable(list);
    }

    /**
     * 导出网约车信息列表
     */
    //@RequiresPermissions("driver:info:export")
    @Log(title = "网约车信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbDriverCarInfo tbDriverCarInfo)
    {
        List<TbDriverCarInfo> list = tbDriverCarInfoService.selectTbDriverCarInfoList(tbDriverCarInfo);
        ExcelUtil<TbDriverCarInfo> util = new ExcelUtil<TbDriverCarInfo>(TbDriverCarInfo.class);
        util.exportExcel(response, list, "网约车信息数据");
    }

    /**
     * 获取网约车信息详细信息
     */
    //@RequiresPermissions("driver:info:query")
    @GetMapping(value = "/{onlineCarInfoId}")
    public AjaxResult getInfo(@PathVariable("onlineCarInfoId") Integer onlineCarInfoId)
    {
        return success(tbDriverCarInfoService.selectTbDriverCarInfoByOnlineCarInfoId(onlineCarInfoId));
    }

    /**
     * 新增网约车信息
     */
    //@RequiresPermissions("driver:info:add")
    @Log(title = "网约车信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbDriverCarInfo tbDriverCarInfo)
    {
        return toAjax(tbDriverCarInfoService.insertTbDriverCarInfo(tbDriverCarInfo));
    }

    /**
     * 修改网约车信息
     */
    //@RequiresPermissions("driver:info:edit")
    @Log(title = "网约车信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbDriverCarInfo tbDriverCarInfo)
    {
        return toAjax(tbDriverCarInfoService.updateTbDriverCarInfo(tbDriverCarInfo));
    }

    /**
     * 删除网约车信息
     */
    //@RequiresPermissions("driver:info:remove")
    @Log(title = "网约车信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{onlineCarInfoIds}")
    public AjaxResult remove(@PathVariable Integer[] onlineCarInfoIds)
    {
        return toAjax(tbDriverCarInfoService.deleteTbDriverCarInfoByOnlineCarInfoIds(onlineCarInfoIds));
    }
}
